/*
 * @Author: szx
 * @Date: 2022-04-12 12:53:30
 * @LastEditTime: 2022-04-12 12:58:26
 * @Description:
 * @FilePath: \leetcode\800-899\806\806.js
 */
/**
 * @param {number[]} widths
 * @param {string} s
 * @return {number[]}
 */
var numberOfLines = function (widths, s) {
    let len;
    const MAXLEN = 100;
    const res = [1, 0];
    for (let i of s) {
        len = widths[i.charCodeAt() - 97];
        if (res[1] + len <= MAXLEN) {
            res[1] += len;
        } else {
            res[1] = len;
            res[0]++;
        }
    }
    return res;
};
